On Migration: undefined method `to_sym' for nil:NilClass?

This is a problem that I have had with rails migrations. You misspelled or misordered a field with its name. Here is what you can do.

This is a problem that I have had with rails migrations. You misspelled or misordered a field with its name. Here is what you can do.

If you have only done one migration since the problem. Rake db:rollback. That will get you to the mistake and you can change the problem which I will talk about more later.

If it is not the last migration keep going with rake db:rollback until you are there and the problem is fixed. The problem is something like this. Notice the order on the first one and the spelling on the second one.

These are two problems that have giving me the same situation you are in right now which is that to_sym bs. For example; :books, :integer, :name #here I have `integer` before the name :books, :name, :integr #here I have the order right but spelling is a problem. Let me know if you have more questions.

If you cannot rake db:rollback then make a new migration, drop the table giving the problem, and regenerate. I've had to do that before. Just make sure you get your order right.

Thanks Sam. Unfortunately "rake db:rollback" is still giving me the to_sym bs. This seriously needs to be fixed in Rails, it's a blatant problem -_- – EricR Jan 8 at 15:55 yeah, it's really lame.

– Codeglot Jan 8 at 15:59 Then drop your table and migrate it again. Hope you don't have lots of data :) – Codeglot Jan 8 at 16:00 Even a drop causes the error. Migration is rendered completely useless right now.

– EricR Jan 8 at 16:48 1 Please describe fully your environment – Daniel Jan 8 at 18:23.

As you mentioned in your comments to codeglot once the record is in your database you still ge t the error when trying to remove the column. :books, :name, :inntegr #here I have the order right but spelling is a problem. To overcome this problem you can manually run sql commands in your migration def self.

Up execute "ALTER TABLE books DROP COLUMN name" end hope this helps.

Thanks! Great tip – EricR Nov 19 at 19:49.

You can also fix the database using a database tool. I had the same problem and used the great application "Base" for MacOS X. It allows you to change the field type of sqlite databases.In the background it just creates a new table with the modified fields and copies the data from the original one.

Worked for me!

If you face the same issue on rollback again, try to remove the faulty column in the database manually. (There is a nice Firefox plugin called SQLite Manager. ) Then run the rollback command, fix the issue in the migration file, and finally migrate again.

This will help you stay in the constraints of Rails migration.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions